package org.lzy.shop.adapter

import android.content.Context
import android.view.ViewGroup
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder
import org.lzy.shop.R
import org.lzy.shop.response.HomeGoodAllResponse
import org.lzy.shop.util.setUrl

class HomeCategorAllAdapter : BaseQuickAdapter<HomeGoodAllResponse.ListDTO, QuickViewHolder>()  {

    override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): QuickViewHolder {
        return QuickViewHolder(R.layout.item_home_all, parent)
    }

    override fun onBindViewHolder(holder: QuickViewHolder, position: Int, item: HomeGoodAllResponse.ListDTO?) {
        item?.let {
            setUrl(item.mainPic, holder.getView(R.id.item_recommand_pic))
            holder.setText(R.id.item_recommand_title, item.title)
            holder.setText(R.id.item_recommand_subtitle, item.subTitle)
            holder.setText(R.id.item_recommand_price, "￥" + item.price)
            holder.setText(R.id.item_recommand_sell, "已售 " + item.sold)
        }
    }
}